/*
 * All rights Reserved, Designed By HerDao
 * Copyright:    Copyright(C) 2020-2099
 * Company:      HerDao Ltd.
 */
package com.boots.easyexcel.filling;

import java.util.List;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.google.common.collect.Lists;

/**
 * @author：OprCalf
 * @date：2021-1-15 9:40:21
 */
public class FillingExport {

    public static void main(String[] args) {
        final String templateFileName = "D:\\template.xlsx";
        final String fileName = "D:\\templatewrite.xlsx";
        // 创建用户列表
        final List<Filling> fillings = Lists.newArrayList();
        // 新增用户列表
        fillings.add(new Filling("hhh", "小红"));
        fillings.add(new Filling("aaa", "小军"));
        fillings.add(new Filling("sss", "小化"));
        fillings.add(new Filling("ddd", "小天"));
        fillings.add(new Filling("fff", "小白"));

        final ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build();

        final WriteSheet writeSheet = EasyExcel.writerSheet().build();
        final FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.FALSE).build();
        // 填充两行list
        excelWriter.fill(fillings, fillConfig, writeSheet);
        excelWriter.finish();
    }

}
